﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using Baza.EF.DAL;
using Baza.EF.BLL;

namespace Pep_3014_3070.Customers
{
    public partial class Customers : System.Web.UI.MasterPage
    {
        public List<ad_Customer_Reservation_By_CustomerID_Result> rezervacijeCustomerID
        {
            get
            {
                if (Session["rezervacijeCustomer"] == null)
                {
                    Session["rezervacijeCustomer"] = new List<ad_Customer_Reservation_By_CustomerID_Result>();
                }
                return (List<ad_Customer_Reservation_By_CustomerID_Result>)Session["rezervacijeCustomer"];
            }
            set
            {
                Session["rezervacijeCustomer"] = value;
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {

                checkTipKorisnika();
                if (rezervacijeCustomerID.Count != 0)
                    countRezervation.InnerText = rezervacijeCustomerID.Count.ToString();
                else
                    countRezervation.InnerText = (0).ToString();
            }
        }
        private void checkTipKorisnika()
        {
            if (HttpContext.Current.User.Identity.IsAuthenticated)
            {
                if (Convert.ToInt32(Session["TipKorisnika"]) == 3)
                {
                    Response.Redirect("/UsersHome");
                }
                else if (Convert.ToInt32(Session["TipKorisnika"]) == 1)
                {
                    Response.Redirect("/OwnersHome");
                }
            }
        }
    }
}